// 数字每三位加逗号
export const toThousands = (num: number | string) => {
  let result = ''
  const numArr = `${num}`.split('.')
  const int = numArr[0]
  const decimal = numArr[1] ? '.' + numArr[1] : ''
  for (let n = int.length - 1; n >= 0; n--) {
    result = int[n] + result
    if ((int.length - n) % 3 === 0 && n !== 0) {
      result = ',' + result
    }
  }
  return result + decimal
}
